#!/usr/bin/python
import cherrypy
from comm.proj import *

class TaobaoPost:
	def index(self):
		return "taobao post"
	index.exposed = True
	def getProduct(self, uid=None, page=None):
		if not page: page = '1'
		if not uid: uid = 'abc'
		raise cherrypy.HTTPRedirect('/taobao/list/listProduct?uid=%s&page=%s' % (uid,page) )
		#raise cherrypy.InternalRedirect('/taobao/list/listProduct?uid=%s&page=%s' % (uid,page) )
	getProduct.exposed = True

class TaobaoList:
	def index(self):
		return "taobao post"
	index.exposed = True
	def listProduct(self, uid=None, page=None):
		class pdct:
			def __init__(self,name,url):
				self.name = name
				self.url = url
		lst = [pdct('aa1','#'),pdct('aa2','#'),pdct('aa3','#'),pdct('aa4','#'),pdct('aa5','#')]
		tpl = Proj.tpl_loader.load('taobao/product_list.html')
		return tpl.generate(pdlst=lst).render('html', doctype='html')
	listProduct.exposed = True
	
class Taobao:
	post = TaobaoPost()
	list = TaobaoList()
	def index(self):
		tpl = Proj.tpl_loader.load('taobao/default.html')
		return tpl.generate(title='Hoho,I got it!').render('html', doctype='html')
	index.exposed = True

